package com.kalaqia.im.library.msg;

import com.hyphenate.chat.EMChatManager;
import com.hyphenate.chat.EMChatRoomManager;
import com.hyphenate.chat.EMClient;
import com.hyphenate.chat.EMMessage;

import java.util.List;

import javax.inject.Named;

import dagger.Module;
import dagger.Provides;
import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.annotations.BackpressureSupport;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Function;
import io.reactivex.functions.Predicate;

/**
 * function:
 * project:kalaqia
 * describe:
 * created owner:kalaqia 421407393@qq.com
 * created date:2017/8/16 16:01
 */
//<editor-fold desc="version update log">
// updare owner:kalaqia  421407393@qq.com
// update datetime:2017/8/16 16:01 
// update remark:
//</editor-fold>
@Module
public class MsgModule {

    @Provides
    public Observable<EMChatRoomManager> provideEMChatRoomManagerObservable() {
        return Observable.just(EMClient.getInstance().chatroomManager());
    }

    @Provides
    public Observable<EMMessage> provideEMMessage(Observable<EMChatManager> observable) {
        return observable.concatMap(EMMessageObservable::new)
                .concatMap(Observable::fromIterable);
    }

//    @Provides
//    public Observable<EMChatRoom> provideEMChatRoomObservable(Observable<EMChatRoomManager> observable) {
//        return observable.concatMap(new Function<EMChatRoomManager, ObservableSource<? extends EMChatRoom>>() {
//            @Override
//            public ObservableSource<? extends EMChatRoom> apply(@NonNull EMChatRoomManager manager) throws Exception {
//                return new EMChatRoomJoinObservable(manager,);
//            }
//        });
//    }

}
